package edu.ntu.cloudroid.model.profile;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.FetchGroup;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import edu.ntu.cloudroid.model.GAEData;
import edu.ntu.cloudroid.model.UserData;

/**
 * Represents a person in the social network.
 * 
 * All data/policies has been abstracted out, and accessible via Services
 * 
 * @author Milind, s.braghin, ttadinh
 * 
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@FetchGroup(name = ProfileData.FETCH_GROUP_NAME, members = {})
public class ProfileData implements Serializable, GAEData
{
	 private static final long serialVersionUID = 1L;

	public static final String FETCH_GROUP_NAME = "withCollections";

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;


	@Persistent
	private String emailAddress;			

	@Persistent	
	private Key defaultPrivacyPreference;
	
	@Persistent
	private int privacyPreferenceId;

	@Persistent
	private int policyCombinationId;
	
	@Persistent
	private int dataId;
	
	public void setPolicyCombiningAlg(int id){
		this.policyCombinationId = id;
	}
	
	public int getPolicyCombiningAlgId(){
		return this.policyCombinationId;
	}
	
	public int getDataId() {
		return dataId;
	}

	public void setDataId(int dataId) {
		this.dataId = dataId;
	}

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}


	public Key getDefaultPrivacyPreference() {
		return defaultPrivacyPreference;
	}

	public void setDefaultPrivacyPreference(Key defaultPrivacyPreference) {
		this.defaultPrivacyPreference = defaultPrivacyPreference;
	}

	public int getPrivacyPreferenceId() {
		return privacyPreferenceId;
	}

	public void setPrivacyPreferenceId(int privacyPreferenceId) {
		this.privacyPreferenceId = privacyPreferenceId;
	}

	@Override
	public UserData getMetaData(Object param) throws Exception {
		return new ProfileInfo(this.emailAddress, this.dataId, this.policyCombinationId);
	}
						
}
